home *** CD-ROM | disk | FTP | other *** search
- --------------------------------------------------------------------------------
- -- Weapon Ghost Rocket + Projectile Rocket
- -- Original Carnage Contest Weapon
- -- Script by DC, August 2009, www.UnrealSoftware.de
- --------------------------------------------------------------------------------
-
- -- Setup Tables
- if cc==nil then cc={} end
- cc.ghostrocket={}
- cc.ghostrocket.rocket={}
-
- -- Load & Prepare Ressources
- cc.ghostrocket.gfx_wpn=loadgfx("weapons/launcher.bmp") -- Weapon Image
- setmidhandle(cc.ghostrocket.gfx_wpn)
- cc.ghostrocket.gfx_pro=loadgfx("weapons/ghostrocket.bmp") -- Projectile Image
- setmidhandle(cc.ghostrocket.gfx_pro)
- cc.ghostrocket.sfx_attack=loadsfx("rocketrelease.wav") -- Attack Sound
-
- --------------------------------------------------------------------------------
- -- Weapon: Ghost Rocket
- --------------------------------------------------------------------------------
-
- cc.ghostrocket.id=addweapon("cc.ghostrocket","Ghost Rocket",cc.ghostrocket.gfx_pro,0,2) -- Add Weapon (0 uses, first round 2)
-
- function cc.ghostrocket.draw() -- Draw
- setblend(blend_alpha)
- setalpha(1)
- setcolor(220,120,255)
- drawinhand(cc.ghostrocket.gfx_wpn,6,0)
- -- HUD chargebar
- if weapon_charge>0 and weapon_shots==0 then
- hudchargebar(weapon_charge,100)
- end
- -- HUD Crosshair
- if weapon_shots==0 then
- hudcrosshair(6,3)
- end
- end
-
- function cc.ghostrocket.attack(attack) -- Attack
- if (weapon_shots<=0) then
- -- Charge
- if (attack==1) then
- weapon_charge=weapon_charge+1 -- Increase charge
- end
- -- Fire a projectile (on release/full charge)
- if (attack==0 and weapon_charge>0) or (weapon_charge>=100) then
- -- No more weapon switching!
- useweapon(0)
- playsound(cc.ghostrocket.sfx_attack)
- weapon_shots=weapon_shots+1
- id=createprojectile(cc.ghostrocket.rocket.id)
- projectiles[id]={}
- -- Ignore collision with current player at beginning
- projectiles[id].ignore=playercurrent()
- -- Set initial position of projectile
- projectiles[id].x=getplayerx(0)+(6*getplayerdirection(0))+math.sin(math.rad(getplayerrotation(0)))*10.0
- projectiles[id].y=getplayery(0)+3-math.cos(math.rad(getplayerrotation(0)))*10.0
- -- Set speed of projectile
- projectiles[id].sx=math.sin(math.rad(getplayerrotation(0)))*(weapon_charge/100.0)*10.0
- projectiles[id].sy=-math.cos(math.rad(getplayerrotation(0)))*(weapon_charge/100.0)*10.0
- -- Effects
- recoil(2)
- -- End Turn
- endturn()
- end
- end
- end
-
- --------------------------------------------------------------------------------
- -- Projectile: Rocket
- --------------------------------------------------------------------------------
-
- cc.ghostrocket.rocket.id=addprojectile("cc.ghostrocket.rocket") -- Add Projectile
-
- function cc.ghostrocket.rocket.draw(id) -- Draw
- -- Setup draw mode
- setblend(blend_alpha)
- setalpha(0.5)
- setcolor(255,255,255)
- setscale(1,1)
- -- Calculate projectile rotation
- setrotation(math.deg(math.atan2(projectiles[id].sx,-projectiles[id].sy)))
- -- Draw projectile
- drawimage(cc.ghostrocket.gfx_pro,projectiles[id].x,projectiles[id].y)
- -- Draw Arrow if out of Screen
- outofscreenarrow(projectiles[id].x,projectiles[id].y)
- end
-
- function cc.ghostrocket.rocket.update(id) -- Update
- rot=math.deg(math.atan2(projectiles[id].sx,-projectiles[id].sy))
- -- Particle Tail
- particle(p_smoke,projectiles[id].x-math.sin(math.rad(rot))*7,projectiles[id].y+math.cos(math.rad(rot))*7)
- particlespeed(math.random(-2,2)*0.1,math.random(-2,2)*0.1)
- particlefadealpha(0.01)
- particle(p_lightpuff,projectiles[id].x-math.sin(math.rad(rot))*6,projectiles[id].y+math.cos(math.rad(rot))*6)
- particlecolor(150,0,200+math.random(0,50))
- particlefadealpha(0.04)
- -- Wind + Gravity influence on speed
- projectiles[id].sx=projectiles[id].sx+getwind()
- projectiles[id].sy=projectiles[id].sy+getgravity()
- -- Move (in substep loop for optimal collision precision)
- msubt=math.ceil(math.max(math.abs(projectiles[id].sx),math.abs(projectiles[id].sy))/3)
- msubx=projectiles[id].sx/msubt
- msuby=projectiles[id].sy/msubt
- for i=1,msubt,1 do
- projectiles[id].x=projectiles[id].x+msubx
- projectiles[id].y=projectiles[id].y+msuby
- -- Collision
- if collision(col3x3,projectiles[id].x+math.sin(math.rad(rot))*3,projectiles[id].y-math.cos(math.rad(rot))*3,0,1,1)==1 then
- if playercollision()~=projectiles[id].ignore or objectcollision()>0 then
- -- Cause damage
- arealdamage(projectiles[id].x,projectiles[id].y,120,60)
- -- Destroy terrain
- terrainexplosion(projectiles[id].x,projectiles[id].y,30,1)
- -- Crater
- grey=math.random(0,40)
- if math.random(0,1)==1 then
- terrainalphaimage(gfx_crater100,projectiles[id].x,projectiles[id].y,math.random(6,9)*0.1,grey,grey,grey)
- else
- terrainalphaimage(gfx_crater125,projectiles[id].x,projectiles[id].y,math.random(6,9)*0.1,grey,grey,grey)
- end
- -- Free projectile
- freeprojectile(id)
- break
- end
- else
- projectiles[id].ignore=0
- end
- -- Water
- if (projectiles[id].y)>getwatery()+5 then
- -- Effects
- particle(p_waterhit,projectiles[id].x,projectiles[id].y)
- playsound(sfx_hitwater1)
- -- Free projectile
- freeprojectile(id)
- break
- end
- end
- -- Scroll to projectile
- scroll(projectiles[id].x,projectiles[id].y)
- end